#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>

typedef struct linkwd
{
	int val;
	struct linkwd* next;
}lik;


lik* liknode(int x)
{
	lik* ret = (lik*)malloc(sizeof(lik));
	if (!ret)
	{
		return NULL;
	}
	ret->val = x;
	ret->next = NULL;
	return ret;
}


void likpushfront(lik** p,int x)
{
	lik* new = liknode(x);
	if (*p == NULL)
	{
		*p = new;
		return;
	}
	lik* cur = *p;
	new->next = cur->next;
	cur->next = new;
}

void removeElements(lik** head, int val)
{
	lik* cur1;
	lik* cur2 = (lik*)malloc(sizeof(lik));
	if (!cur2)
	{
		return NULL;
	}
	cur2->next = cur1 = *head;
	while (cur1)
	{
		if (cur1->val != val)
		{
			cur1 = cur1->next;
			cur2 = cur2->next;
		}
		else
		{
			cur1 = cur1->next;
			cur2->next = cur1;
		}
		if ((*head)->val == val)
			*head = cur1;
	}

	return head;
}









int main()
{
	lik* p = NULL;
	//likpushfront(&p, 7);
	/*likpushfront(&p, 7);
	likpushfront(&p, 7);
	likpushfront(&p, 7);
	likpushfront(&p, 7);
	likpushfront(&p, 7);
	likpushfront(&p, 7);
	likpushfront(&p, 7);
	likpushfront(&p, 7);*/
	removeElements(&p, 7);
	return 0;
}

































